function addCol() {
    var originCol = $('#add-word-card-zero');
    var newCol = originCol.clone(true,true);
    newCol.removeAttr("id");
    newCol.css("display","inline-block");
    newCol.insertBefore('#add-word-sign-wrapper');
}
$(document).ready(function(){
    addCol();
    $(".add-word-card-delete").click(function(){
        $(this).parent().remove();
    });
    $("#add-word-plus-sign").click(function(){
        addCol();
    });

    var added = false;
    $("#add-word-finish-sign").click(function(){
        if (added) {
            return;
        }
        is_sure(function(){
            let map = Object.create(null);
            $(".add-word-card[id!='add-word-card-zero']").each(function (){
                k = $(this).children().eq(0).val();
                v = $(this).children().eq(1).val();
                map[k] =v;
            });
            let data = JSON.stringify(map);
            $.post("CreatePrivateList.php",{
                data:data,
            },function(data){
                if(data == "0") {
                    added = true;
                    $("#notice").text("单词表已添加！2秒后跳转");
                    setTimeout(function(){
                        window.location.replace("/index.php");
                    },2000);
                }else{
                    $("#notice").text(data);
                }
            });
        });
    });
});